﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tblUserDAL : SqlDataProvider
	{

		#region[tblUser_GetbyAll]
		public DataTable tblUser_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblUser_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblUser_GetbyId]
		public DataTable tblUser_GetById(tblUserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblUser_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_uid", Data._uid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblUser_GetbyTop]
		public DataTable tblUser_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblUser_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblUser_Insert]
		public void tblUser_Insert(tblUserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblUser_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_uname", Data._uname));
				cmd.Parameters.Add(new SqlParameter("@_uaccount", Data._uaccount));
				cmd.Parameters.Add(new SqlParameter("@_upassword", Data._upassword));
				cmd.Parameters.Add(new SqlParameter("@_ustatus", Data._ustatus));
				cmd.Parameters.Add(new SqlParameter("@_ucreatedate", Data._ucreatedate));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblUser_Update]
		public void tblUser_Update(tblUserInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblUser_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_uid", Data._uid));
				cmd.Parameters.Add(new SqlParameter("@_uname", Data._uname));
				cmd.Parameters.Add(new SqlParameter("@_uaccount", Data._uaccount));
				cmd.Parameters.Add(new SqlParameter("@_upassword", Data._upassword));
				cmd.Parameters.Add(new SqlParameter("@_ustatus", Data._ustatus));
				cmd.Parameters.Add(new SqlParameter("@_ucreatedate", Data._ucreatedate));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblUser_Delete]
		public void tblUser_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tblUser_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_uid", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}